package com.xm.xmapp.customview;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.xm.xmapp.R;
import com.xm.xmapp.app.CodeConstant;

public class PhoneDialog extends Dialog  {


	Activity activity;



	public PhoneDialog(Context context, int theme) {
		super(context, theme);
	}

	public PhoneDialog(Activity activity) {
		this(activity, R.style.share_Dialog);
		this.activity = activity;

	}

	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub

		return super.onTouchEvent(event);

	}

	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialog_phone);
		
		
		TextView phone = (TextView) findViewById(R.id.phone);
		
		TextView quxiao = (TextView) findViewById(R.id.quxiao);
		
		TextView email = (TextView) findViewById(R.id.email);
		
		phone.setText("客服电话："+CodeConstant.phone);
		
		email.setText("邮箱："+CodeConstant.email);
		
		email.setVisibility(View.GONE);
		
		quxiao.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				dismiss();
			}
		});
		
		
		
		phone.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
	            Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+CodeConstant.phone));  
	            activity.startActivity(intent);
			}
		});
		
		Window window = getWindow();
		WindowManager.LayoutParams wl = window.getAttributes();
		wl.alpha = 1.0f;
		wl.gravity = Gravity.BOTTOM;
		WindowManager wm = activity.getWindowManager();
		wl.width = wm.getDefaultDisplay().getWidth();
		window.setAttributes(wl);
		setCancelable(true);
		setCanceledOnTouchOutside(true);
	

	}

	
	
	

}
